{"ast":null,"code":"import React from'react';import Title from\"./utils/Title\";import{Context}from\"./index\";import{observer}from\"mobx-react-lite\";import{Route,Routes,useNavigate}from\"react-router-dom\";import{Auth,Im,Profile,Contacts}from\"./pages\";import{browserRouteAuth,browserRouteContacts,browserRouteIm,browserRouteProfile}from\"./routes\";import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var App=function App(){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var navigate=useNavigate();Title();React.useEffect(function(){if(localStorage.getItem(\"\".concat(process.env.REACT_APP_NAME_TOKEN))){store.checkAuth();}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);React.useEffect(function(){store.getAuth()?navigate(browserRouteIm):navigate(browserRouteAuth);// eslint-disable-next-line react-hooks/exhaustive-deps\n},[store.getAuth()]);if(store.getLoading()){return/*#__PURE__*/_jsx(\"section\",{className:\"global_loading\",children:/*#__PURE__*/_jsx(\"div\",{className:\"loading\"})});}return/*#__PURE__*/_jsxs(Routes,{children:[/*#__PURE__*/_jsx(Route,{path:browserRouteAuth,element:/*#__PURE__*/_jsx(Auth,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteIm,element:/*#__PURE__*/_jsx(Im,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteProfile,element:/*#__PURE__*/_jsx(Profile,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteContacts,element:/*#__PURE__*/_jsx(Contacts,{})})]});};export default observer(App);","map":{"version":3,"names":["React","Title","Context","observer","Route","Routes","useNavigate","Auth","Im","Profile","Contacts","browserRouteAuth","browserRouteContacts","browserRouteIm","browserRouteProfile","App","useContext","store","navigate","useEffect","localStorage","getItem","process","env","REACT_APP_NAME_TOKEN","checkAuth","getAuth","getLoading"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/App.tsx"],"sourcesContent":["import React, {FC} from 'react';\nimport Title from \"./utils/Title\";\nimport {Context} from \"./index\";\nimport {observer} from \"mobx-react-lite\";\nimport {Route, Routes, useNavigate} from \"react-router-dom\";\nimport {Auth, Im, Profile, Contacts} from \"./pages\";\nimport {browserRouteAuth, browserRouteContacts, browserRouteIm, browserRouteProfile} from \"./routes\";\n\nconst App: FC = () => {\n    const {store} = React.useContext(Context);\n    const navigate = useNavigate();\n\n    Title();\n\n    React.useEffect( () => {\n        if (localStorage.getItem(`${process.env.REACT_APP_NAME_TOKEN}`)) {\n            store.checkAuth();\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    React.useEffect( () => {\n        (store.getAuth())? navigate(browserRouteIm): navigate(browserRouteAuth);\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.getAuth()]);\n\n    if (store.getLoading()) {\n        return (\n            <section className='global_loading'>\n                <div className=\"loading\"></div>\n            </section>\n        )\n    }\n\n    return (\n      <Routes>\n          <Route path={browserRouteAuth} element={<Auth/>} />\n          <Route path={browserRouteIm} element={<Im/>} />\n          <Route path={browserRouteProfile} element={<Profile/>} />\n          <Route path={browserRouteContacts} element={<Contacts/>} />\n      </Routes>\n    );\n}\n\nexport default observer(App);\n"],"mappings":"AAAA,MAAOA,MAAK,KAAY,OAAO,CAC/B,MAAOC,MAAK,KAAM,eAAe,CACjC,OAAQC,OAAO,KAAO,SAAS,CAC/B,OAAQC,QAAQ,KAAO,iBAAiB,CACxC,OAAQC,KAAK,CAAEC,MAAM,CAAEC,WAAW,KAAO,kBAAkB,CAC3D,OAAQC,IAAI,CAAEC,EAAE,CAAEC,OAAO,CAAEC,QAAQ,KAAO,SAAS,CACnD,OAAQC,gBAAgB,CAAEC,oBAAoB,CAAEC,cAAc,CAAEC,mBAAmB,KAAO,UAAU,CAAC,wFAErG,GAAMC,IAAO,CAAG,QAAVA,IAAO,EAAS,CAClB,sBAAgBf,KAAK,CAACgB,UAAU,CAACd,OAAO,CAAC,CAAlCe,KAAK,mBAALA,KAAK,CACZ,GAAMC,SAAQ,CAAGZ,WAAW,EAAE,CAE9BL,KAAK,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